﻿using System;

namespace LA6
{
    /// <summary>
    /// The class that implements a linked list as a stack.
    /// </summary>
    class Stack : LinkedList
    {
        /// <summary>
        /// Pushes the given name on the stack.
        /// </summary>
        /// <param name="nameValue">The name to push on the stack.</param>
        public void Push(string nameValue)
        {
            InsertAtFront(nameValue);
        }
        
        /// <summary>
        /// Pops an item from the stack.
        /// </summary>
        /// <returns>The name of the item popped from the stack.</returns>
        public string Pop()
        {
            ListNode node = RemoveFromFront();
            if (node == null)
                return null;
            else
                return node.Name;
        }
    }
}
